<template>
  <div class="goodsDetail">
    <img class="goodsImage" v-bind:src="this.$Api.API_BASE_PIC + goodsDetail.img" />
    <div>商品名称: {{goodsDetail.name}}</div>
    <div>售价: {{goodsDetail.price}} $ </div>
    <div class="goodsColors">
      <button v-for="color in goodsDetail.colors" v-bind:key="goodsDetail.id">{{color}}</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'goodsDetail',
  data() {
    return {
      goodsDetail: {
        name: "",
        price: 0,
        img: "./assets/logo.png",
        colors: []
      }
    }
  },
  created() {
    let that = this;

    //获取动态路由参数
    //let id = this.$route.params.id;

    this.$post(`${this.$Api.API_GOODS_DETAILS}?id=${this.$route.query.id}`).then(res => {
      that.goodsDetail = res.data;
    }, err => {
      alert(err.message)
    })
  },
}
</script>


<style scoped>
h1,
h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

.goodsImage {
  height: 400px;
  width: 400px;
  margin: 10px;
  border: solid 1px blueviolet;
}

.goodsColors {
  margin: 10px
}

.goodsDetail {
  border: solid 2px black;
}
</style>
